/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 */

package com.sys.midware.mongo.core.mongoOP;

import com.mongodb.DBObject;

/**
 * <b>ClassName:</b> MongoPage.java <br/>
 * <b>Description:</b> TODO <br/>
 * <b>Date:</b>     2016年1月13日 下午1:06:11<br/> 
 * @author   mobing
 * @version  	 
 */
public class MongoPage {

    
    private int skip;  
    
    private int limit;  
    
//    private int pageNo;
//    
//    private int pageSize;
      
    private MongoSort sort;  
      
    private MongoPage(){}
    
    public static MongoPage start() {
        return new MongoPage();
    }
    
    public MongoPage skip(int skip) {  
        this.skip = skip;  
        return this;  
    }  
  
    public MongoPage limit(int limit) {  
        this.limit = limit;  
        return this;  
    }  
      
    public MongoPage pagination(int pageNo,int pageSize) {  
        this.skip = (pageNo - 1) * pageSize;  
        this.limit=pageSize;
        return this;  
    } 
    
    public int getSkip() {  
        return skip;  
    }  
  
    public int getLimit() {  
        return limit;  
    }  
  
    public MongoSort sort(MongoSort sort) {  
        this.sort= sort;
        if ( this.sort == null) {  
            this.sort = new MongoSort();  
        }  
        return this.sort;  
    }  
      
    public DBObject getSortObject() {  
        if (this.sort == null) {  
            return null;  
        }  
        return this.sort.getSortObject();  
    }  
}

